//
//  Extension+UIImageView.swift
//  SinaWeibo
//
//  Created by 王朝阳 on 2016/10/24.
//  Copyright © 2016年 wangzhaoyang. All rights reserved.
//

import UIKit
extension UIImageView{
    
    /// 创建图片
    ///
    /// - parameter imgName: 图片名称
    ///
    /// - returns: 返回一张图片
    convenience init(imgName: String) {
        self.init(image: UIImage(named: imgName))
    }
    func hm_setImage(withUrlString: String?, placeholderImgName: String?){
        // 获取图片的 url
        let url = URL(string: withUrlString ?? "")
        // 判断他是否为 nil
        guard let u = url else {
            return
        }
        // 调用 sdWebImage 的方法
        self.sd_setImage(with: u, placeholderImage: UIImage(named: placeholderImgName ?? ""))
    }

}
